<template>
    <el-upload v-model:file-list="fileList[typeof $attrs.prop]" v-bind="{ ...config, ...$attrs }">
        <slot></slot>
    </el-upload>
</template>
<script lang="ts">
export const exceed = (files: File[], uploadFiles: UploadUserFile[]) => {};
export const beforeUpload = (attrs: any, rawFile: UploadRawFile) => {};
export const preview = (uploadFile: UploadFile) => {};
export const error = (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles) => {};
</script>
<script lang="ts" setup>
import type { UploadFiles, UploadFile, UploadRawFile, UploadUserFile } from 'element-plus';
defineProps({
    fileList: {
        type: Object,
        required: true,
        default: () => ({})
    }
});
const config = {
    'show-file-list': true, //是否显示已上传文件列表
    'auto-upload': false, //是否在选择文件后立即进行上传
    'on-exceed': exceed, //当超出限制时，执行的钩子函数
    'on-preview': preview, //点击已上传的文件列表中已上传文件的预览事件
    'on-error': error, //当上传失败时，执行的钩子函数
    'before-upload': (rawFile: UploadRawFile) => beforeUpload(getCurrentInstance()?.attrs, rawFile) //上传文件之前的钩子，参数为上传的文件，返回 false 或者 Promise 对象，返回 false 表示停止上传。
};
</script>
